package com.tjetc.vo;

import lombok.Data;

/**
 * AI响应数据结构
 */
@Data
public class AIResponse {
    private String id;
    private String object;
    private long created;
    private String model;
    private Choice[] choices;
    private Usage usage;

    @Data
    public static class Choice {
        private int index;
        private Message message;
        private String finishReason;
    }

    @Data
    public static class Message {
        private String role;
        private String content;
    }

    @Data
    public static class Usage {
        private int promptTokens;
        private int completionTokens;
        private int totalTokens;
    }

    /**
     * 获取AI回复的内容
     * @return AI回复的文本内容
     */
    public String getContent() {
        if (choices != null && choices.length > 0 && choices[0].getMessage() != null) {
            return choices[0].getMessage().getContent();
        }
        return null;
    }

    /**
     * 检查响应是否成功
     * @return 是否成功
     */
    public boolean isSuccess() {
        return choices != null && choices.length > 0 && 
               choices[0].getMessage() != null && 
               choices[0].getMessage().getContent() != null;
    }
} 